#include<iostream>
#include<vector>
#include<sys/types.h>
#include<unistd.h>

using namespace std;

void submisson()
{
    while(true)
    {
        cout<<"i am a subprocess,my pid is:"<<getpid()<<"my father process pid is:"<<getppid()<<endl;
        sleep(5);
    }
}

const int num=10;

int main()
{
    cout<<"i am a process,my pid is:"<<getpid()<<"my father process pid is:"<<getppid()<<endl;
    vector<pid_t> allchild;
    int i=0;
    for(i=0;i<num;i++)
    {
        pid_t id=fork();
        if(id==0)   
        {
            submisson();
        }
        allchild.push_back(id);
    }
    cout<<":我所有孩子的pid为:"<<endl;
    for(auto child:allchild)
    {
        cout<<child<<endl;
    }
    while(true)
    {
        cout<<"i am father process,my pid is:"<<getpid()<<endl;
        sleep(10);
    }   
}

